package edu.nf.bs.dao.impl;

import edu.nf.bs.dao.StationsMapper;
import edu.nf.bs.dao.TransferMapper;
import edu.nf.bs.entity.Stations;
import edu.nf.bs.entity.Transfer;
import edu.nf.bs.util.MyBatisUtils;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class TransferMapperImpl implements TransferMapper {
    @Override
    public List<Integer> queryTransferStatus(String logisticsId) {
        SqlSession sqlSession = MyBatisUtils.getSqlSession(true);
        TransferMapper mapper = sqlSession.getMapper(TransferMapper.class);
        List<Integer> integers = mapper.queryTransferStatus(logisticsId);
        sqlSession.close();
        return integers;
    }

    @Override
    public Transfer queryTransferAddress(String logisticsId) {
        SqlSession sqlSession = MyBatisUtils.getSqlSession(true);
        TransferMapper mapper = sqlSession.getMapper(TransferMapper.class);
        Transfer transfer = mapper.queryTransferAddress(logisticsId);
        sqlSession.close();
        return transfer;
    }

    @Override
    public Transfer queryTransferAddress1(String logisticsId) {
        SqlSession sqlSession = MyBatisUtils.getSqlSession(true);
        TransferMapper mapper = sqlSession.getMapper(TransferMapper.class);
        Transfer transfer = mapper.queryTransferAddress1(logisticsId);
        sqlSession.close();
        return transfer;
    }

    @Override
    public List<Transfer> queryLogisticsId(String logisticsId) {
        SqlSession sqlSession = MyBatisUtils.getSqlSession(true);
        TransferMapper mapper = sqlSession.getMapper(TransferMapper.class);
        List<Transfer> transfers = mapper.queryLogisticsId(logisticsId);
        sqlSession.close();
        return transfers;
    }

    @Override
    public Integer addTransfer(Transfer transfer) {
        SqlSession sqlSession = MyBatisUtils.getSqlSession(true);
        TransferMapper mapper = sqlSession.getMapper(TransferMapper.class);
        Integer integer = mapper.addTransfer(transfer);
        sqlSession.close();
        return integer;

    }

    @Override
    public Integer updateTransfer(String transferId) {
        SqlSession sqlSession = MyBatisUtils.getSqlSession(true);
        TransferMapper mapper = sqlSession.getMapper(TransferMapper.class);
        Integer integer = mapper.updateTransfer(transferId);
        sqlSession.close();
        return integer;
    }

    @Override
    public String queryTransferId(String transferId) {
        SqlSession sqlSession = MyBatisUtils.getSqlSession(true);
        TransferMapper mapper = sqlSession.getMapper(TransferMapper.class);
        String s = mapper.queryTransferId(transferId);
        sqlSession.close();
        return s;
    }


}
